var express = require('express');
var Query = require("./data")

var router = express.Router();


/** 首页轮播图数据接口 */
router.get("/banners",async(req,resp) => {
   // 定义sql语句
   let sql = `select * from e_banners`
   let result = await Query(sql)
   // 处理图片路径问题
   result = result.map(value=> {
     return {
       ...value,
       image_src: "http://192.168.11.100:3000/images/" + value.image_src
     }
   })
   
   // 允许跨域数据访问
    resp.header("Access-Control-Allow-Origin","*")
    resp.send({
      errorCode: 200,
      errorMsg: "获取成功",
      user: "",
      data: result
    })
})






module.exports = router;
